package A1_链表;

public class LC_206反转链表_递归 {
    public static class ListNode {
        int val;
        ListNode next;
        ListNode() {}
        ListNode(int val) { this.val = val; }
        ListNode(int val, ListNode next)
        { this.val = val; this.next = next; }
    }
    public ListNode reverseList(ListNode head) {
        return reverse(head,null);
    }
    public ListNode reverse(ListNode cur,ListNode pre){
        if(cur==null)
            return pre;
        ListNode temp=cur.next;
        cur.next=pre;
        return reverse(temp,cur);
    }

}
